import { craeteEffect, effectTypes } from './helper'

/**
 * 提供一个函数，用于产生 put effect
 * 触发action   
 * @param {*} action
 * @return {*} 
 */
export function put(action) {
    return craeteEffect(effectTypes.PUT, { action })
}

/**
 * 处理call effect  
 * @param {*} env
 * @param {*} effect
 * @param {*} next
 */
export function runPutEffect(env, effect, next) {
    const { store } = env
    const { payload: { action } } = effect
    next(store.dispatch(action))
}